package com.hzqy.service.weather;

import com.hzqy.persistence.dao.weather.WeatherForecastCommonDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.service.externalLink.ExternalLinkServiceBean;
import com.hzqy.web.vo.WlContentVo;
import com.hzqy.web.vo.weather.WeatherForecastCommonVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class WeatherForecastCommonServiceBean extends GenericServiceBean<WeatherForecastCommonVo,WeatherForecastCommonDao, Integer>{
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Resource
	private WeatherForecastCommonDao weatherForecastCommonDao;
	@Resource
	private ExternalLinkServiceBean externalLinkServiceBean;
	
	@Override
	public WeatherForecastCommonDao getEntityDao() {
		return weatherForecastCommonDao;
	}
	
	/**
	 * 获取天气预报信息
	 * @param vo
	 * @return
	 */
	public List<WeatherForecastCommonVo> selectWeatherForecastCommonVo(WeatherForecastCommonVo vo){
		WlContentVo wlContentVo = new WlContentVo();
		wlContentVo.setF_wlc_name("前台天气总开关");
		wlContentVo.setSysConfigKey("control_link_ab");
		WlContentVo wlc = externalLinkServiceBean.selectWLContentAvaliable(wlContentVo);//是否可以访问
		List<WeatherForecastCommonVo> voList = null;
		if(wlc!=null){
			if(("10".equals(vo.getF_wfc_source())||"11".equals(vo.getF_wfc_source()))&&vo.getArea_type()!=1){//天气查询时使用的地区类型，目前行业实时与周数据地区用2
				vo.setArea_type(2);
			}else{
				vo.setArea_type(1);
			}
			System.out.println("vo:"+vo);
			voList = weatherForecastCommonDao.selectWeatherForecastCommonVo(vo);
			System.out.println("voList:"+voList);
		}
		
		if(null == voList || voList.size() ==0 ){
			voList = new ArrayList<WeatherForecastCommonVo>();
		}

		return voList;
		
	}
	
}
